{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Domain knowledge discretisation\n",
    "\n",
    "Frequently, when engineering variables in a business setting, the business experts determine the intervals in which they think the variable should be divided so that it makes sense for the business. These intervals may be defined both arbitrarily or following some criteria of use to the business. Typical examples are the discretisation of variables like Age and Income. \n",
    "\n",
    "Income for example is usually capped at a certain maximum value, and all incomes above that value fall into the last bucket. As per Age, it is usually divided in certain groups according to the business need, for example division into  0-21 (for under-aged), 20-30 (for young adults), 30-40, 40-60, and > 60 (for retired or close to) are frequent.\n",
    "\n",
    "Below I will show how this seemingly straightforward method works."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Titanic dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "% matplotlib inline\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>38.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>26.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>35.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>35.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived   Age\n",
       "0         0  22.0\n",
       "1         1  38.0\n",
       "2         1  26.0\n",
       "3         1  35.0\n",
       "4         0  35.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# load the numerical variables of the Titanic Dataset\n",
    "data = pd.read_csv('titanic.csv', usecols = ['Age', 'Survived'])\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The variable Age contains missing data, that I will fill by extracting a random sample of the variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def impute_na(data, variable):\n",
    "    df = data.copy()\n",
    "    \n",
    "    # random sampling\n",
    "    df[variable+'_random'] = df[variable]\n",
    "    \n",
    "    # extract the random sample to fill the na\n",
    "    random_sample = data[variable].dropna().sample(df[variable].isnull().sum(), random_state=0)\n",
    "    \n",
    "    # pandas needs to have the same index in order to merge datasets\n",
    "    random_sample.index = df[df[variable].isnull()].index\n",
    "    df.loc[df[variable].isnull(), variable+'_random'] = random_sample\n",
    "    \n",
    "    return df[variable+'_random']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# let's fill the missing data\n",
    "data['Age'] = impute_na(data, 'Age')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Age\n",
    "### Original distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    891.000000\n",
       "mean      29.700348\n",
       "std       14.563654\n",
       "min        0.420000\n",
       "25%       21.000000\n",
       "50%       28.000000\n",
       "75%       38.000000\n",
       "max       80.000000\n",
       "Name: Age, dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Age.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Age</th>\n",
       "      <th>Age_buckets_labels</th>\n",
       "      <th>Age_buckets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>38.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>26.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>35.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived   Age Age_buckets_labels   Age_buckets\n",
       "0         0  22.0              20-40  (20.0, 40.0]\n",
       "1         1  38.0              20-40  (20.0, 40.0]\n",
       "2         1  26.0              20-40  (20.0, 40.0]\n",
       "3         1  35.0              20-40  (20.0, 40.0]\n",
       "4         0  35.0              20-40  (20.0, 40.0]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's divide Age into the buckets that we described in the intro cell\n",
    "\n",
    "# bucket boundaries\n",
    "buckets = [0,20,40,60,1000]\n",
    "\n",
    "# bucket labels\n",
    "labels = ['0-20', '20-40', '40-60', '>60']\n",
    "\n",
    "# discretisation\n",
    "data['Age_buckets_labels'] = pd.cut(data.Age, bins=buckets, labels = labels, include_lowest=True)\n",
    "data['Age_buckets'] = pd.cut(data.Age, bins=buckets, include_lowest=True)\n",
    "\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Age</th>\n",
       "      <th>Age_buckets_labels</th>\n",
       "      <th>Age_buckets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>886</th>\n",
       "      <td>0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>887</th>\n",
       "      <td>1</td>\n",
       "      <td>19.0</td>\n",
       "      <td>0-20</td>\n",
       "      <td>(-0.001, 20.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>888</th>\n",
       "      <td>0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>0-20</td>\n",
       "      <td>(-0.001, 20.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>889</th>\n",
       "      <td>1</td>\n",
       "      <td>26.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>890</th>\n",
       "      <td>0</td>\n",
       "      <td>32.0</td>\n",
       "      <td>20-40</td>\n",
       "      <td>(20.0, 40.0]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Survived   Age Age_buckets_labels     Age_buckets\n",
       "886         0  27.0              20-40    (20.0, 40.0]\n",
       "887         1  19.0               0-20  (-0.001, 20.0]\n",
       "888         0  15.0               0-20  (-0.001, 20.0]\n",
       "889         1  26.0              20-40    (20.0, 40.0]\n",
       "890         0  32.0              20-40    (20.0, 40.0]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Above we can observe the buckets into which each Age observation was placed. For example, age 27 was placed into the 20-40 bucket.\n",
    "\n",
    "Let's explore the number of observations and survival rate per bucket after this arbitrary discretisation method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e79a12438>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEeCAYAAACExd7cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFV9JREFUeJzt3X/wXXV95/Hni4SiRUSQkLIE/SLGH6CVSsrYxVktbAWK\nY9hZxTBdDS3baBe3ut3WDbrd3U43nTDduqXdMl1WKVlXpbHKkgUWZCPotFsJAfFH+JkFUshAErC6\nOqO0ie/9456Um6/55nu/+d5vDt/PPh8zmXvu55xzzzufgdc9+dxzPidVhSSpXYf1XYAkaW4Z9JLU\nOINekhpn0EtS4wx6SWqcQS9JjTPoJalxBr0kNc6gl6TGLey7AIDjjjuuJiYm+i5DkuaVu+++++mq\nWjTddiMFfZLHgO8Ce4DdVbUsybHAnwITwGPARVX11932lwOXdtv/alXdeqDPn5iYYPPmzaOUIknq\nJNk2ynYzGbr52ao6vaqWde9XAxuraimwsXtPklOBFcBpwHnAVUkWzOA4kqQxms0Y/XJgXbe8Drhw\nqP26qnq2qh4FtgJnzuI4kqRZGDXoC/hfSe5OsqprW1xVT3bLTwGLu+UTgceH9n2ia5Mk9WDUH2Pf\nXFXbkxwP3JbkgeGVVVVJZjTfcfeFsQrgZS972Ux2lSTNwEhn9FW1vXvdCVzPYChmR5ITALrXnd3m\n24GThnZf0rVN/syrq2pZVS1btGjaH40lSQdp2qBPcmSSo/YuA28DvglsAFZ2m60EbuiWNwArkhyR\n5GRgKbBp3IVLkkYzytDNYuD6JHu3/3RV3ZLkLmB9kkuBbcBFAFW1Jcl64D5gN3BZVe2Zk+olSdOa\nNuir6hHgDftpfwY4Z4p91gBrZl2dJGnWnAJBkhr3vJgCQc9/E6tv6ruEkTy29oK+S5Cedzyjl6TG\nGfSS1DiDXpIaZ9BLUuMMeklqnEEvSY0z6CWpcQa9JDXOoJekxhn0ktQ4g16SGmfQS1LjDHpJapxB\nL0mNM+glqXEGvSQ1zqCXpMYZ9J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jXMuW7UmyQv6uanfymDUDtrf5OeSZodz+jVpxu7H05/\nDPhtQ16aG57Ra15I8kfAWZOar6yqP+mjnukk+SjwrknNn62qNX3Uo/+/GfSS1DivupGkxhn0ktQ4\ng16SGmfQS1LjDHpJatz/A3eQXSgCIyzSAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e799f6208>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# number of passengers per age bucket\n",
    "data.groupby('Age_buckets_labels')['Age'].count().plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e79e0ef98>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEeCAYAAACNLn6mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGENJREFUeJzt3X+wX3V95/HnyxuxNiJWuaCbBBMkirEKg1dqV0aLrmyi\nnQZHXWEdKf5oTNfUdTu2ZuvW2R3XHZj+1C6aTWlKdYppraZm5Ur8LbNVNBelQJBgNmJJRiSgpetU\nC5H3/vE9kW++XrjnJt/cb+49z8dM5n7P58f3vr9n9HUPn/M956SqkCR1x6NGXYAkaW4Z/JLUMQa/\nJHWMwS9JHWPwS1LHGPyS1DEGvyR1jMEvSR1j8EtSxywadQHTOfnkk2v58uWjLkOS5o0bbrjhnqoa\nbzP2uAz+5cuXMzU1NeoyJGneSPLttmNd6pGkjjH4JaljDH5J6hiDX5I6xuCXpI4x+CWpYwx+SeoY\ng1+SOsbgl6SOOS6v3D0Wlm+8ZtQlzOiOy14+6hIkdYBH/JLUMa2CP8nqJLuT7Emy8RHGPS/JwSSv\nmu1cSdLcmDH4k4wBVwBrgFXAxUlWPcy4y4FPzXauJGnutDni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DobcbGE/yiwBJHt0szzyS1zRjz6O3FHIfcAdwTtN+Dr2l\nJejduvjVzfLMoT9Mh1wLXAZck+TEGWr5f/SWhA6dwzipqiaB/wSc1XLfnAh8p1neeu1A36ubffM0\n4PSmlh3ArzfjSfL0JIv7JyU5HdhbVe8DPg48p2UtWuA84tdcuhi4fKDto8AzgX30bi98J/A1eqF9\nf7OU8b4kJ9H73+sfA7se4Xf8KMnXgUfz0LmAjwKXJNkFfIVmOaSqdiV5D/DFJD8Gvk7vGzo0/R9p\nQn878DJ6f7imq+UqYFOSHwJrgI8n+Rl6R+W/2XLf/G5T24Hm54l9ff8AfBV4PLC+qn6U5Ep6a/9f\nS2/t6QBw4cB7/jt6J7sfoPdUrv/RshYtcN6rR8eFJI9r7s//JHoh94LpbuIm6eh5xK/jxSeaE7En\nAO829KVjxyN+zTtJrgBeMND83qr681HUM5Mk7wRePdD8kap6zyjqkQx+SeoYv9UjSR1j8EtSxxj8\nktQxBr8kdYzBL0kd8/8B2T5H1lIoe+kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e79d83ef0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# survival rate per age bucket\n",
    "data.groupby('Age_buckets_labels')['Survived'].mean().plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The majority of people on the Titanic were between 20-40 years of age. We can see that all the age bins have the same Survival rate. Therefore, most likely, this is not a good method of grouping the Age variable to improve model predictive performance.\n",
    "\n",
    "**So when would we use a discretisation method like this?**\n",
    "\n",
    "Well for example, if the business was organising marketing campaigns, and they decide that they will run 4 different marketing campaigns each one targeting each of this buckets, then, dividing age into these groups makes sense for further analysis."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Lending Club\n",
    "\n",
    "Let's explore discretisation using domain knowledge in a different business scenario. I will use the loan book from the peer to peer lending company Lending Club. This dataset contains information on loans given to people, and the financial characteristics of those people as well as the loan performance."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>annual_inc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>24000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>30000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>12252.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>49200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>80000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   annual_inc\n",
       "0     24000.0\n",
       "1     30000.0\n",
       "2     12252.0\n",
       "3     49200.0\n",
       "4     80000.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# I will load only the income declared by the borrower for the demonstration\n",
    "\n",
    "data = pd.read_csv('loan.csv', usecols=['annual_inc'])\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    8.873750e+05\n",
       "mean     7.502759e+04\n",
       "std      6.469830e+04\n",
       "min      0.000000e+00\n",
       "25%      4.500000e+04\n",
       "50%      6.500000e+04\n",
       "75%      9.000000e+04\n",
       "max      9.500000e+06\n",
       "Name: annual_inc, dtype: float64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.annual_inc.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e79f06cf8>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAEJCAYAAABohnsfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGZBJREFUeJzt3W+MnWV63/HvLzhL3E1gbTYZWYbENLibAtvdBNfQJoom\nsWJ7d6tAJUDe0uCmFm4EXW0kpAbyolYXWYIXWxK2hcoKDobSBZdka5qERa7JNKkS/qZsHCDEzgLB\nroEGe6HeCBKzV1+ce+AwGTO3x/YM4/l+pKN5znWe+z73dcTuz8+fOZOqQpKkHt812wuQJM0dhoYk\nqZuhIUnqZmhIkroZGpKkboaGJKmboSFJ6mZoSJK6GRqSpG4LZnsBJ9rHP/7xWrZs2bTHf/vb3+aj\nH/3oiVvQHGP/9m//87P/p5566i+r6vun2u+UC41ly5bx5JNPTnv82NgYo6OjJ25Bc4z927/9j872\nMmZFkpd69vP0lCSpm6EhSeo2ZWgk+USSp4cebyb5xSSLk+xMsqf9XDQ05sYke5M8n2TNUP2iJLvb\na7clSaufnuT+Vn8sybKhMevbe+xJsv7Eti9JOhZThkZVPV9Vn66qTwMXAX8FfA24AdhVVcuBXe05\nSc4H1gEXAGuB25Oc1qa7A7gGWN4ea1t9A3Coqs4DbgVuaXMtBjYBFwMrgU3D4SRJmlnHenpqFfDn\nVfUScCmwrdW3AZe17UuB+6rq7ap6AdgLrEyyBDijqh6twR/xuHvCmPG5HgBWtaOQNcDOqjpYVYeA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mtJOveZ\nq7p6S/IPgF8DPlNVr8/Q2mZCT/8rgPtaYHwc+GySI1X132ZmiSddz2ewD3i9qr4NfDvJ7wGfAk6F\n0Ojp/+eBm2twUWNvkheAHwEen5klfnjNx9NTPV9L8iBwdbuL6hLgjao6MNMLPUmm7D/JDwK/Cfzc\nKfgvyyn7r6pzq2pZVS0DHgCuPYUCA/r+N7AD+IkkC5L8HQbfLP3cDK/zZOnp/y8YHGWRZAT4BPDN\nGV3lh9S8O9Koo3wtSZJfaK//JwZ3zHwW2Av8FYN/dZwSOvv/t8BZwO3tX9tH6hT5ErfO/k9pPZ9B\nVT2X5OvAHwPfAX6tqv5k9lZ94nT+N3ATcFeS3Qzuovylqpqv3377Pv5GuCSp23w8PSVJmiZDQ5LU\nzdCQJHUzNCRJ3QwNSZrjkmxN8lqSKe9wS3Jr+yLKp5P8WZJvHdN7efeUJM1tSX4SOMzgO/MuPIZx\nXwB+tKr+Ze8YjzQkaY6rqt9j8KWK70ryw0m+3r477PeT/MgkQz8PfPVY3mve/XKfJM0TW4BfqKo9\nSS4GbmfwXVoAJPkh4FwGfwKgm6EhSaeYJN/L4O/i/NehL908fcJu64AHquqdY5nb0JCkU893Ad+q\nqk9/wD7rgOumM7Ek6RTSvsL9hSRXwLt/wvrdP9vcrm8sAv7wWOc2NCRpjkvyVQYB8Ikk+5JsAK4C\nNiT5BvAM7//rhOuA+2oat896y60kqZtHGpKkboaGJKmboSFJ6mZoSJK6GRqSpG6GhiSpm6EhSepm\naEiSuv1/Elb3sLEqBtEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e79f247b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# let's inspect the distribution of Incomes\n",
    "data.annual_inc.hist(bins=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e7ad5ccc0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGPlJREFUeJzt3X+M1Pd95/Hnq5AQascY7HTEAbqlMpeKHxcnrAhRctUm\nXOptHAX/YbsbuTXuUVPJtOfokNrlKl11fyDhnnpO3J59RSUydtwAR2uB4tCI4Ix6pzsgkDjFYFM2\n9iKzwiBjB259ss/re98f81n8ZT673tnZ2Z3ZnddDGs1n3t/v5zuft9fivZ/P5zuzigjMzMyKfqnZ\nAzAzs9bj4mBmZhkXBzMzy7g4mJlZxsXBzMwyLg5mZpZxcTAzs4yLg5mZZVwczMwsM7vZA6jXrbfe\nGh0dHXX1ffvtt7nhhhsaO6AW55zbg3NuDxPJ+cSJE29ExCfGOm/aFoeOjg6OHz9eV99yuUxXV1dj\nB9TinHN7cM7tYSI5SzpXy3leVjIzs4yLg5mZZVwczMws4+JgZmaZMYuDpE9KeqHwuCrpG5IWSDok\n6Wx6nl/os1VSn6Qzku4oxFdLOpmOPSZJKT5H0p4UPyqpYzKSNTOz2oxZHCLiTETcHhG3A6uB/wM8\nC/QChyNiGXA4vUbScqAHWAF0A49LmpUu9wTwILAsPbpTfCPwVkTcBjwKPNKY9MzMrB7jXVZaB/w8\nIs4B64FdKb4LuCu11wO7I+LdiHgV6APWSFoI3BQRR6Ly5+eequozfK19wLrhWYWZmU298X7OoQf4\nbmqXIuJCar8OlFJ7EXCk0Od8ir2X2tXx4T6vAUTEkKQrwC3AG8U3l7QJ2ARQKpUol8vjHH7F4OBg\n3X2nK+fcHpxze5iKnGsuDpI+CnwN2Fp9LCJC0qT/MeqI2AHsAOjs7Ix6PwTiD820B+fcHpzz5BjP\nzOE3gZ9ExMX0+qKkhRFxIS0ZXUrxAWBJod/iFBtI7ep4sc95Sb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PUnsF129gvcLoG1hf\nSfHNXL+BtTe1FwCvUtm8mp/aC6YoXwFPAd+sis/YvIFPADen9lzgvwNfnck5F3Lv4oM9hxmbL3AD\n8PFC+39S+QWgJXOekh9+Kz2Ar1C5++XnwJ80ezw1jPe7wAXgPSrrhBuprCEeBs4CPyz+kIE/Sbmd\nId3BkOKdwIvp2F/ywQcgPwb8N6Av/Q/3q4U+/ybF+4DfncKcv0BlbfYfgRfS4yszOW/gXwI/TTm/\nCPyHFJ+xORfeu4sPisOMzZfKXZI/S49TpH9/WjVnf0LazMwy7bbnYGZmNXBxMDOzjIuDmZllXBzM\nzCzj4mBmZhkXBzMzy7g4mJlZxsXBzMwy/x+gGG8q7NbYFgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e799956d8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# and now let's look at the lower incomes in more detail\n",
    "data[data.annual_inc<500000].annual_inc.hist(bins=100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can see that the majority of the population earns below 150,000. So we may want to make a cap there."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>annual_inc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>886115.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>73900.859540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>43818.534502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>45000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>64609.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>90000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>499992.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          annual_inc\n",
       "count  886115.000000\n",
       "mean    73900.859540\n",
       "std     43818.534502\n",
       "min         0.000000\n",
       "25%     45000.000000\n",
       "50%     64609.000000\n",
       "75%     90000.000000\n",
       "max    499992.000000"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data.annual_inc<500000].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>annual_inc</th>\n",
       "      <th>Income_buckets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>24000.0</td>\n",
       "      <td>0-45k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>30000.0</td>\n",
       "      <td>0-45k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>12252.0</td>\n",
       "      <td>0-45k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>49200.0</td>\n",
       "      <td>45-65k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>80000.0</td>\n",
       "      <td>65-90k</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   annual_inc Income_buckets\n",
       "0     24000.0          0-45k\n",
       "1     30000.0          0-45k\n",
       "2     12252.0          0-45k\n",
       "3     49200.0         45-65k\n",
       "4     80000.0         65-90k"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# and now let's divide into arbitrary buckets, assuming that these make business sense\n",
    "\n",
    "# bucket interval\n",
    "buckets = [0,45000,65000,90000,150000,1e10]\n",
    "\n",
    "# bucket labels\n",
    "labels = ['0-45k', '45-65k', '65-90k','90-150k', '>150k']\n",
    "\n",
    "# discretisation\n",
    "data['Income_buckets'] = pd.cut(data.annual_inc, bins=buckets, labels = labels, include_lowest=True)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>annual_inc</th>\n",
       "      <th>Income_buckets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>887374</th>\n",
       "      <td>31000.0</td>\n",
       "      <td>0-45k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>887375</th>\n",
       "      <td>79000.0</td>\n",
       "      <td>65-90k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>887376</th>\n",
       "      <td>35000.0</td>\n",
       "      <td>0-45k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>887377</th>\n",
       "      <td>64400.0</td>\n",
       "      <td>45-65k</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>887378</th>\n",
       "      <td>100000.0</td>\n",
       "      <td>90-150k</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        annual_inc Income_buckets\n",
       "887374     31000.0          0-45k\n",
       "887375     79000.0         65-90k\n",
       "887376     35000.0          0-45k\n",
       "887377     64400.0         45-65k\n",
       "887378    100000.0        90-150k"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e7a0cbf28>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAEqCAYAAADpvgyHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG6xJREFUeJzt3X+0XWV95/H3B6OUqUBBIkNDbLDiWLBTLBGZ2lEqLVCd\nEdqCxdUlsVKpo1a7+hNbOzg6zAJnWiy2sAaFApYWKFVBBW2K1P5aQAKi/FAkFShkEFJCwc5U2uB3\n/jjPJSeXm9wnyc3dNznv11pn3X2e/eN+zybkk72f5zw7VYUkST12G7o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SX2jY3Jtm3bfe9ST6b5JYkf5XkJbOU+KNJVif5WpL/NPa7fm/sM3x6\naqqNJMclubXVfP0Mn/etSa5LssdMtST5IUaTBv7PJLe1bd6V5K4kX05y+Vycd+3a/HKfdnUvAw4F\n/g/wN8Ark9wMXAH8dFWtarPQ/jPwbqCq6vvbX/h/1p59AfDSdqzvANYAv15VL0tyDnAK8CHgAuBt\nVXVPe9TreYyeXLg5yxg9V/57gRuSvGhzG7Yvwn0EeFVV3TsVVGPr3wn8GHBCVT3ZnhS4SS1V9Zr2\ndMVPV9VVbb/TgYPaPt81++nUpDM0tKu7uaoeBGhPy1sGPA48VFWr4OkH4JDkh4EPt7avJrkfmAqN\nG6rqm8A3kzwOfKq13w78+yTPBX4I+JN2MQOjKTO25Mr2lLZ7knwd2NKVyZHAX1bVva2+8W9Sn8Lo\nGR0nVNW/bmUtXwYuS/JJ4JOz1CsZGtrlPTm2/BTb/md+/DjfHnv/7XbM3YB/rKrDtuKY079ZW8AG\nNr1t/B0dx7kdOAw4ELh3K2t5HfAq4D8Dv5nk+8ceUSs9g30amkR3AwckeTlA689YBPwV8DOt7cXA\nC9q2s2pXK/cmOantnyQ/MMtuJyXZrT1r4oXtd90HHNbalzK6fQWjR4G+KslB7fjjt6e+CPw8cE2S\n756llm8Ce7b23YClVXUD8OvA3rTJBKXNMTQ0carqX4CfBj6c5EvASkb/oj8P2K1N5X0F8OaqenLz\nR3qGnwFObce8Ezh+lu3/HriZ0XOi31ZV32LU73IvcBdwLnBrq3kdcBrw8Xb8K6Z9pr8GfgX4TJL9\ntlDL5cCvJvkicDDwh+3zfhE4t6r+cSs+ryaQc09Jkrp5pSFJ6mZHuLQDJflN4KRpzX9SVWcOUY+0\nvbw9JUnq5u0pSVI3Q0OS1M3QkCR1MzQkSd0MDUlSt/8PA3moq3swy6sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e79ff55c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.groupby(['Income_buckets'])['annual_inc'].count().plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x4e7a238160>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEqCAYAAAASxTsdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF3BJREFUeJzt3X+0XWWd3/H3h6SoRfAXQR0SmujEMlgFnYjWoSI6WpDW\nUKd2cLlUVJqmS4quqaOZ6lhnpu1C+8NfA6YRGXWNNv4oaJQA6pTRmWEYElAJYQAzIQ5JVYI/UOso\nRr794+xLTq43uecmN2ffy/N+rZV1z3723ud+z869n+w8e+/nSVUhSWrHEX0XIEkaL4Nfkhpj8EtS\nYwx+SWqMwS9JjTH4JakxBr8kNcbgl6TGGPyS1JiFfRcwlWOPPbaWLl3adxmSNG/ceOON91TVolG2\nnZPBv3TpUjZv3tx3GZI0byT5xqjb2tUjSY0x+CWpMQa/JDXG4Jekxhj8ktQYg1+SGmPwS1JjDH5J\naozBL0mNmZNP7mr2LF1zZd8lALDjorP7LkFSxzN+SWqMwS9JjTH4JakxBr8kNcbgl6TGGPyS1BiD\nX5IaY/BLUmMMfklqjMEvSY0x+CWpMQa/JDXG4Jekxhj8ktQYg1+SGjNS8Cc5M8ntSbYlWTPF+pcn\nuTnJliTXJTl5aN2Orv2rSTbPZvGSpJmbdiKWJAuAi4EXADuBTUk2VNWtQ5vdCZxeVd9LchawDnjm\n0PozquqeWaxbknSQRpmB61RgW1VtB0iyHlgJPBD8VXXd0PbXA4tns8iZctYpSdq/Ubp6jgfuGlre\n2bXtz2uBq4aWC/hikhuTrNrfTklWJdmcZPPu3btHKEuSdDBmdc7dJGcwCP7ThppPq6pdSY4DvpDk\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Cc0u0kWwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x4e7a28d1d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(data.groupby(['Income_buckets'])['annual_inc'].count()/np.float(len(data))).plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "We  have captured ~equal amount of borrowers in each of the first 3 buckets, and we see clearly, that a smaller percentage of the loans were disbursed to high earners.\n",
    "\n",
    "**That is all for this demonstration. I hope you enjoyed the notebook, and see you in the next one.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
